package com.health.db.service.sm.impl;

import com.health.db.model.RegisterOrder;
import com.health.db.model.UserLIST;
import com.health.db.service.sm.ISMSSendService;
import com.health.mapp.utils.DateUtils;
import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;

/*
 * 单纯用于发送短信   不去判断短信是否发送成功
 * 
 */
public class SMSSendServiceImpl implements ISMSSendService{
	
	
	private static String serverUrl = "http://gw.api.taobao.com/router/rest";
	private static String appKey = "23312748";
	private static String appSecret =  "d7badcea8b88c4560868f1a4e3c246c9";
	
	@Override
	public void cancleOrder(UserLIST doc, RegisterOrder currerOrder) {
		// TODO Auto-generated method stub
		
		//${docName}医生，用户${userName}取消了您${ScheduleTime}的 一个视频咨询，给您造成了不便。 
		TaobaoClient clients = new DefaultTaobaoClient(serverUrl,appKey ,appSecret);
		AlibabaAliqinFcSmsNumSendRequest AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		AliReq.setSmsParamString("{\"docName\":\" "+doc.getUserName() +"\",\"userName\":\""+currerOrder.getUserName()+"\",\"ScheduleTime\":\""+DateUtils.formatDatetime(currerOrder.getScheduleTime())+"\""+"}");
		AliReq.setRecNum(doc.getUserNo().replace("#", ""));
		AliReq.setSmsTemplateCode("SMS_58335081");
		try {
			clients.execute(AliReq);
		} catch (ApiException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
	}
	@Override
	public void noticeOrder(UserLIST doc, RegisterOrder currerOrder) {
		// TODO Auto-generated method stub
		//${docName}医生，您有一个视频咨询预约将在一小时后开始，请您合理安排时间，及时响应患者视频请求
		TaobaoClient clients = new DefaultTaobaoClient(serverUrl,appKey ,appSecret);
		AlibabaAliqinFcSmsNumSendRequest AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		AliReq.setSmsParamString("{\"docName\":\" "+doc.getUserName()+"\""+"}");
		AliReq.setRecNum(doc.getUserNo().replace("#", ""));
		AliReq.setSmsTemplateCode("SMS_58305050");
		try {
			clients.execute(AliReq);
		} catch (ApiException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		//您预约的${docName}医生的${count}分钟视频咨询一个小时后就要开始啦，记得登录首儿健康汇app和专家面对面咨询哦。 
		AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		AliReq.setSmsParamString("{\"docName\":\" "+doc.getUserName() +"\",\"count\":\""+currerOrder.getScheduleDuration()+"\""+"}");
		AliReq.setRecNum(currerOrder.getUserContact());
		AliReq.setSmsTemplateCode("SMS_58165027");
		try {
			clients.execute(AliReq);
		} catch (ApiException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	@Override
	public void regsiterOrder(UserLIST doc, RegisterOrder currerOrder) {
		
		//${docName}医生，用户${userName}预约了您${ScheduleTime}的 一个视频咨询，请您合理安排时间，及时响应患者视频请求。 
		TaobaoClient clients = new DefaultTaobaoClient(serverUrl,appKey ,appSecret);
		AlibabaAliqinFcSmsNumSendRequest AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		AliReq.setSmsParamString("{\"docName\":\" "+doc.getUserName() +"\",\"userName\":\""+currerOrder.getUserName()+"\",\"ScheduleTime\":\""+DateUtils.formatDatetime(currerOrder.getScheduleTime())+"\""+"}");
		AliReq.setRecNum(doc.getUserNo().replace("#", ""));
		AliReq.setSmsTemplateCode("SMS_58195083");
		try {
			clients.execute(AliReq);
		} catch (ApiException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		//您预约的${docName}医生${count}分钟视频咨询已预约成功，预约时间：${ScheduleTime}，请您按时就诊。
		AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		AliReq.setSmsParamString("{\"docName\":\" "+doc.getUserName() +"\",\"count\":\""+currerOrder.getScheduleDuration()+"\",\"ScheduleTime\":\""+DateUtils.formatDatetime(currerOrder.getScheduleTime())+"\""+"}");
		AliReq.setRecNum(currerOrder.getUserContact());
		AliReq.setSmsTemplateCode("SMS_58210002");
		try {
			clients.execute(AliReq);
		} catch (ApiException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
	//${docName}医生您好！您有一份健康档案未处理！请您及时处理！
	@Override
	public void notice85605027(String  docName,String docPhone) {
		
		TaobaoClient clients = new DefaultTaobaoClient(serverUrl,appKey ,appSecret);
		AlibabaAliqinFcSmsNumSendRequest AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		AliReq.setSmsParamString("{\"docName\":\" "+docName +"\""+"}");
		AliReq.setRecNum(docPhone);
		AliReq.setSmsTemplateCode("SMS_85605027");
		try {
			clients.execute(AliReq);
		} catch (ApiException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
	
	//${docName}医生您好！您有一份健康档案需要重新编辑并提交！如有问题请及时联系首儿健康小助手。
	@Override
	public void notice85765027(String  docName,String docPhone) {
		
		TaobaoClient clients = new DefaultTaobaoClient(serverUrl,appKey ,appSecret);
		AlibabaAliqinFcSmsNumSendRequest AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		AliReq.setSmsParamString("{\"docName\":\" "+docName +"\""+"}");
		AliReq.setRecNum(docPhone);
		AliReq.setSmsTemplateCode("SMS_85765027");
		try {
			clients.execute(AliReq);
		} catch (ApiException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
	
	//您在首儿健康汇为宝宝建立的健康档案已完成。请及时查看！感谢您使用首儿健康汇！
	@Override
	public void notice85735036(String phone) {
		
		TaobaoClient clients = new DefaultTaobaoClient(serverUrl,appKey ,appSecret);
		AlibabaAliqinFcSmsNumSendRequest AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		//AliReq.setSmsParamString("{\"docName\":\" "+docName +"\""+"}");
		AliReq.setRecNum(phone);
		AliReq.setSmsTemplateCode("SMS_85735036");
		try {
			clients.execute(AliReq);
		} catch (ApiException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
	
	//${docName}医生您好！您提供的健康档案，家长需要您的答疑，请您及时查看并回复！
	@Override
	public void notice85785039(String  docName,String docPhone) {
		
		TaobaoClient clients = new DefaultTaobaoClient(serverUrl,appKey ,appSecret);
		AlibabaAliqinFcSmsNumSendRequest AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		AliReq.setSmsParamString("{\"docName\":\" "+docName +"\""+"}");
		AliReq.setRecNum(docPhone);
		AliReq.setSmsTemplateCode("SMS_85785039");
		try {
			clients.execute(AliReq);
		} catch (ApiException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
	
	
	
	//您好！平台有用户反馈,反馈内容为${feedDesc},用户电话为${phone}。
	@Override
	public void notice85730029(String phone,String feedDesc,String feedPhone) {
		
		TaobaoClient clients = new DefaultTaobaoClient(serverUrl,appKey ,appSecret);
		AlibabaAliqinFcSmsNumSendRequest AliReq = new AlibabaAliqinFcSmsNumSendRequest();
		AliReq.setSmsType("normal");
		AliReq.setSmsFreeSignName("首儿健康汇");
		AliReq.setSmsParamString("{\"feedDesc\":\" "+feedDesc+"\",\"phone\":\""+feedPhone +"\""+"}");
		AliReq.setRecNum(phone);
		AliReq.setSmsTemplateCode("SMS_86055042");
		try {
			clients.execute(AliReq);
		} catch (ApiException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
	
	
}
